#pragma once

#include <cstdint>
#include <string>
#include <cassert>

#if defined(_WIN32)
#include <winsock2.h>
#include <ws2tcpip.h>
#include <iphlpapi.h>
#elif defined(__linux__)
#include <netdb.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#endif

#if defined(_WIN32)
typedef SOCKET socket_type;
typedef socklen_t socket_len_type;
typedef SOCKADDR_IN in_addr_type;
typedef SOCKADDR_IN6 in6_addr_type;
typedef SOCKADDR socket_addr_type;
const socket_type invalid_socket = INVALID_SOCKET;
const unsigned long IN4ADDR_ANY = INADDR_ANY;
const struct in6_addr IN6ADDR_ANY = in6addr_any;
#define SHUT_RD SD_RECEIVE
#define SHUT_WR SD_SEND
#define SHUT_RDWR SD_BOTH
#elif defined(__linux__)
typedef int socket_type;
typedef socklen_t socket_len_type;
typedef struct sockaddr_in in_addr_type;
typedef struct sockaddr_in6 in6_addr_type;
typedef struct sockaddr socket_addr_type;
typedef int HANDLE;
const socket_type invalid_socket = -1;
const unsigned long IN4ADDR_ANY = INADDR_ANY;
const struct in6_addr IN6ADDR_ANY = in6addr_any;
#define SOCKET_ERROR -1
#endif

